home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / grafix / tools / pstoedit / pstoedit.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-02-26  |  2.5 KB  |  97 lines

  1. /*  $VER: pstoedit.rexx 1.0 (15.1.96) Terje Pedersen */
  2.  
  3. /* You need to do the following in order for it to work:         */
  4.  
  5. /* Copy pstoedit.pro to libx11: or change the libx11: reference        */
  6. /* Make sure ghostscript is installed properly                */
  7. /* Get a hold of rexxdossupport from aminet if you haven't already     */
  8.  
  9. /* note: This script it much slower than the unix script on large files */
  10.  
  11. if ~show(l,'rexxdossupport.library') then
  12.   if ~addlib('rexxdossupport.library',0,-30,2) then
  13.     exit
  14.  
  15. OPTIONS RESULTS
  16.  
  17. Format ="fig"; Magnify=1
  18.  
  19. REDEF="/textastext true def"
  20. DOESCAPE="/escapetext false def"
  21. DISPLAYOPTION="-dNODISPLAY"
  22. SUFFIX="fig"
  23.  
  24. parse arg args
  25. if ReadArgs(args,'File/M,Format/K,Magnify/K,TextPoly/S,Display/S') then do
  26.   FileName=""
  27.   do i = 0 by 1 for file.count
  28.     FileName = FileName file.i
  29.   end
  30.   
  31.   if TextPoly then REDEF="/textastext false def"
  32.   if Display then DISPLAYOPTION=""
  33.  
  34.   if Format = "fig" then SUFFIX="fig"
  35.   if Format = "mif" then SUFFIX="mif"
  36.   if Format = "tgif" then SUFFIX="tgif"
  37.   if Format = "ps"  then DOESCAPE="/escapetext true def"
  38.  
  39.    ADDRESS COMMAND
  40.   'copy' 'libx11:pstoedit.pro' 't:tmp1'
  41.   ADDRESS REXX
  42.   Open('temp','t:tmp1','a')
  43.   Writeln('temp',REDEF)
  44.   Writeln('temp',DOESCAPE)
  45.   Close('temp')
  46.  
  47. /* start ghostscript */
  48.   ADDRESS COMMAND
  49.   'gs' '-dWRITESYSTEMDICT' DISPLAYOPTION '-q' 't:tmp1' FileName 'quit.ps < NIL: > t:tmp2'
  50.  
  51.   'search' ' t:tmp2 SEARCH Error '
  52.  
  53.   if( RC = 0 ) then do 
  54.     say 'Ghostscript seems to have failed on file ' FileName
  55.     say "Look into" t:tmp2 "for error messages from GhostScript"
  56.     return -1
  57.   end
  58.   else do
  59.     'makeedit' '-m' Magnify '-f' Format ' -o t:tmp1 < t:tmp2'
  60.     ADDRESS REXX
  61.     if Format = "fig" then do
  62.       Open('temp1','t:tmp1','r')
  63.       Open('temp2','t:tmp2','w')
  64.       Open('temp3','t:tmp3','w')
  65.       do i = 0 by 1 for 5
  66.         in = Readln('temp1')
  67.         Writeln('temp2',in)
  68.       end
  69.       do while ~EOF('temp1')
  70.         in = Readln('temp1')
  71.     if subword(in,1,1) = "#color" then do
  72.       Writeln('temp2',delword(in,1,1))
  73.     end
  74.     else do
  75.       Writeln('temp3',in)
  76.         end
  77.       end
  78.       Close('temp1')
  79.       Close('temp2')
  80.       Close('temp3')
  81.       output=FileName
  82.       n=index(FileName,".")
  83.       if n>0 then output=delstr(FileName,n)
  84.       output= output'.'SUFFIX
  85.       ADDRESS COMMAND
  86.       'join' 't:tmp2 t:tmp3 to ' output
  87.       'delete' 't:tmp1 t:tmp2 t:tmp3 quiet'
  88.       ADDRESS REXX
  89.       say 'Output file written to' output
  90.     end
  91.   end
  92.   return 0
  93. end
  94. else do
  95.   say 'pstoedit File/M [Format/K] [Magnify/K] [TEXTPOLY] [DISPLAY]'
  96. end
  97.